home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / stay42.zip / STAYRES.420 < prev    next >
Text File  |  1986-08-14  |  26KB  |  516 lines

  1. {$R+}
  2. {$C-}
  3. {-----------------------------------------------------------------------------}
  4. {         "  Look, Dave, I know you're trying to be helpful. But              }
  5. {           the fault is either in the ... system - or in YOUR                }
  6. {           test procedures.  My information processing is perfectly          }
  7. {           normal. "                                                         }
  8. {                                        Arthur C. Clark  -  " 2001 "         }
  9. {-----------------------------------------------------------------------------}
  10. { Stayres Version 4.15 }
  11. {
  12.   Copyright (C) LaneFerris 1985,1986.
  13.   Distributed to the Public Domain for use without Profit.
  14.  
  15.   A  Turbo  "stay-resident" program clobbers the Dos register stack.  It
  16.   jumps over the Turbo run-time initialization code that would set up the
  17.   program registers  and environment.   Secondly,  a  Turbo TSR (Terminate
  18.   and stay-resident) could not ordinarily issue file I/O since that would
  19.   clobber Dos interrupt registers.
  20.  
  21.   Therefore,  the following code proposes an inline solution, recovering the
  22.   Turbo entry  stack  for  "stay-resident" programs  and allowing those
  23.   programs to issue Dos I/O and other interrupts.
  24.  
  25.   This Turbo stay-resident demo has been put together to perform both Dos I/O
  26.   and Bios interrupts. It has been tested for re-entrancy and recursiveness
  27.   on an IBM PC with PCDOS 2.0, 2.1, 3.0, 3.1 .
  28.  
  29.   R_U_N   I_N_S_T_R_U_C_T_I_O_N_S
  30.   Separate the include files, compile to a COM file using STAYRES.420 (or the
  31.   current release level) as the  Main file. Then execute the command file
  32.   from the DOS prompt.
  33.  
  34.   Use the Turbo Compiler Options window to set the Maximum free dynamic
  35.   memory  between 300-400 paragraphs. If you get $FF runtine errors or
  36.   "allocation error", "cannot load Command.Com", then adjust the mAximum free
  37.   value to something reasonable but less than your maximum memory (minus
  38.   20K). This program can ONLY run as a COM file.
  39.  
  40.    Activate with the default hotkey (Alt-F9).  Stayres will also free its
  41.    memory and return to Dos with the Cntl-F9 key at the last "Press a key"
  42.    prompt (Illustrated in the Stayxit routine).
  43.  
  44.  
  45.                       The Hunter's Helper
  46.  
  47.                       Lane Ferris
  48.                       4268 26th St
  49.                       San Francisco,Ca. 94131
  50.                       Compuserv 70357,2716
  51.  
  52.  If you find this program useful, $15 will aid in its evolution and upkeep.
  53.  
  54. }
  55. { Authors: Lane  Ferris   (Stay Resident/Exit Code)         }
  56. {          Neil J. Rubenking (Directory code and ideas)     }
  57. {          Karson W. Morrison (Stay Resident modifications) }
  58. {          Lynn A. Canning (Window coding revisions)        }
  59. {          Bela Lubkin (INT24 processing)                   }
  60. {          Other Public Gurus on whose shoulders we stand.  }
  61. {
  62.  PURPOSE:
  63.        This code will serve as a template to create other "Stay  Resident"
  64.        programs  in  Turbo  Pascal(tm).   This  code  intercepts  Int  16,
  65.        (or INT 9) displacing the original Interrupt Vector  to a Turbo inline
  66.        service procedure. During  execution  of  other  programs,  it  can be
  67.        invoked by the special key combination  specified  by  "Our_HotKey"
  68.        (in  this  case Alt-F9.) }
  69.  
  70. {
  71.  Modifications:
  72.           7.85 - Replace Windows with a more simple form/less code.
  73.                     Replace Window Array with Pointers/Heap form.
  74.                     Re-issue termination Keyboard Read / pass back to user
  75.                     Would like to back up Instruction Ptr by two bytes before
  76.                     the Int 16 ($CD16) but it might be a "long call" by
  77.                     some other Kbd interceptor (chirp chirp chrip)... and
  78.                     thats "trouble in River City".
  79.                     Clean up RmWin "incorrect" attribute bugs. If screen
  80.                     isnt cleared, we get border attribute, not text attrb.
  81.                     Remove last window at Termination Time (Ctrl-Home).
  82.           8.85 - Version 3.10 Changes
  83.                     1) Save 40 words in StaySave/Rstr to avoid clobbering
  84.                        Dos Stack when entering Dos with Turbo Write(ln) caused
  85.                        by Int 21 Function 5  (Writln(Lst,..)) which re-issues
  86.                        Int 16.
  87.                     2) Change Int 68 to Int 67 to Avoid collisions with
  88.                        Dos 3.1 on an AT.
  89.                     3) Correct "Press a Key..." to accept any "Key..."
  90.                        (not just Cr).
  91.                     4) Check Int16 function. Jmp directly to Int16 if not
  92.                        a character request. Avoids 40 word Save/Restore
  93.                        overhead.
  94.           9.85 - Version 3.20 changes
  95.                     When returning to user program, pass back a fake
  96.                     "Ctrl-key" scan code to allow immediate re-execution
  97.                     of the TSR (Terminate Stay Resident) program. Also
  98.                     solves SideKick incessant bird caws.
  99.           9.85 - Version 3.2C
  100.                     When saving/restoring the stack, save 40 words or less
  101.                     depending on stack size (0-Sp = stack size) to avoid
  102.                     overflowing into SS:0 when stack is less than 40 words.
  103.                     Put back the "wait for user key logic" at Demo end.
  104.                     Beep like SuperKick if Key is OurKey
  105.           9.85 - Version 3.31
  106.                     Futz around with the "wait for user key logic", allow
  107.                     the Our_key to pass, but beep user to show we aint
  108.                     gonna activate, cuz our InUse bit is still set.
  109.                     Clean up the documentation and duplicate instructions in
  110.                     StaySave/Rstr.
  111.                     Change Int67 to Int60 for Fun and Profit and get around
  112.                     Mark Stanock's use of those locations.
  113.           9.85 - Version 3.32
  114.                     Changes made by Karson W. Morrison
  115.                     Modified the STAYRES.331 version to remove all coding
  116.                     that was not necessary for the stayres routines.
  117.                     The coding associated with the demo was put into
  118.                     seperate include files.  The coding for a revised windo.inc
  119.                     file was placed into the stayres program.  The windo
  120.                     routines were changed to allow background and forground
  121.                     colors and to allow borders of one line, two lines, or
  122.                     no lines.  Read the doc info. in the windo.inc file.
  123.                     Revisions for the windo.inc file were made by
  124.                     Lynn A. Canning.  The windo routine will now allow a
  125.                     window of 1,1,80,25.
  126.          10.85 - Version 3.33     l.ferris
  127.                     Correct inverted parameters in Stay Windo include file
  128.                     Delete unused variables and code in demo code.
  129.                     Rename files to keep with Version/Release/Modification
  130.                     numbering scheme.
  131.                     Remove necessity for using User Interrupt locations in
  132.                     low storage. Use Far calls to original interrupt.
  133.                     Change Alt-F10 to Alt-F9 to avoid common conflicts.
  134.                     Change Cntl-Home to Cntl-F9 keys to avoid common conflicts.
  135.          12.85 - Version 3.40   l.ferris
  136.                     Clean up Window errors, add 3rd window options. Correct
  137.                     Alpa/Beta errors. Say Thanks to Neil once again.
  138.           4.86 - Version 4.00
  139.                     Rewrite stay-resident interface. Avoid manipulating
  140.                     DOS or Users interrupted stack.
  141.                     Intercepts Interrupts 9, 8, 13, 21, 28
  142.           6.86 -    Replace INT 9 processing with an INT 16 equivalent.
  143.                     Works better with mutitasking environments. Leave
  144.                     INT 9 as an option.
  145.                - Version 4.10
  146.                     Addition of Neil RubenKing's Clock Demonstration.
  147.                     Great work Neil. Thanks! Co